<?php
/**
 * @Created on 2020/01/15
 * @Author QQ 1026269609@qq.com
*/
namespace app\admin\controller;
use think\Controller;

class Base extends Controller
{
    public function _initialize(){
        if(!session('uid')){
            $this->redirect('Login/index');
        }
        $controller=request()->controller();
        $action=request()->action();
        //session存在时，不需要验证的权限
        $not_check=array('Index/index','Index/password','Index/index','Index/welcome','Index/soudata');
        if(in_array($controller . '/' . $action,$not_check)){
            return true;
        }
        //权限验证
//        halt(get_auth($controller,session('uid')));
        if(!get_auth($controller.'/'.$action,session('uid')) && session('uid') != 1){
            //uid=1为管理员
            $this->error('无权限操作');
        }
    }
}

